/*
 * 存款利率计算器v2.0（4分）
 *
 * v1.0，见：02_week02/3_Deposit_Interest_Rate_Calculator_v1.c
 */

#include <stdio.h>
#include <math.h>

int main() {
	setbuf(stdout, NULL);

	// NOTE: Variable declaration
	int year;
	double rate, capital, deposit;
	char flag;


	// NOTE: Inputs
	printf("Input rate, year, capital:");
	scanf("%lf,%d,%lf", &rate, &year, &capital);

	// 获取计息方式标记
	printf("Compound interest (Y/N)?");
	scanf(" %c", &flag);


	// NOTE: Process
	// 根据计息方式计算本息和
	if (flag == 'Y' || flag == 'y') {
		deposit = capital * pow(1 + rate, year);
	} else if (flag == 'N' || flag == 'n') {
		deposit = capital * (1 + rate * year);
	}

	// NOTE: Outputs
	printf("deposit = %.4f\n", deposit);

	// NOTE: Ending
	return 0;
}